<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .item{
            float: left;
            width: 100px;
            height: 50px;
            border: 1px solid #ccc;
            margin: 0 10px;
        }
    </style>
</head>
<body>
    <div class="container">
        <h2 class="page-header">点击切换颜色</h2>
        <div class="item"></div>
        <div class="item"></div>
        <div class="item"></div>
    </div>
    <script>
        let items = document.querySelectorAll('.item');
        for(let i = 0; i < items.length; i++) {
            items[i].addEventListener('click', function() {
                for(let i = 0; i < items.length; i++) {
                   items[i].style.backgroundColor = '';
                }
                this.style.backgroundColor = 'pink';
            })
        }
    </script>
</body>
</html>